<?php

namespace app\index\controller;

use app\admin\model\BannerModel;
use app\admin\model\LeadModel;
use app\admin\model\MyfcModel;
use app\admin\model\NavModel;
use app\admin\model\NoticeModel;
use app\admin\model\ShfwModel;
use app\admin\model\ThemeModel;
use app\admin\model\TrednsModel;
use app\admin\model\YqljModel;
use app\common\controller\Frontend;

class Index extends Frontend
{

    protected $noNeedLogin = '*';
    protected $noNeedRight = '*';
    protected $layout = '';

    public function index()
    {
        //导航条表查询
        $nav = NavModel::select();
        //轮播图表
        $banner = BannerModel::select();
        //新闻公告表1
        $notice1 = NoticeModel::order(['id'=>'desc'])->limit(3)->select();
        //新闻公告表2
        $notice2 = NoticeModel::order(['id'=>'desc'])->limit(3,3)->select();
        //党建引领表
        $lead = LeadModel::order(['id'=>'desc'])->limit(3)->select();
        //教研动态表1
        $trends = TrednsModel::order(['id'=>'desc'])->find();
        //教研动态表2
        $trends2 = TrednsModel::order(['id'=>'desc'])->limit(1,5)->select();
        //社会服务表
        $shfw = ShfwModel::order(['id'=>'desc'])->find();
        //主题活动表
        $theme = ThemeModel::order(['id'=>'desc'])->limit(4)->select();
        //马院风采表
        $myfc = MyfcModel::select();
        //友情链接表
        $yqlj = YqljModel::select();
        //向HTML传数据
        $this->assign('nav', $nav);
        $this->assign('banner', $banner);
        $this->assign('notice1', $notice1);
        $this->assign('notice2', $notice2);
        $this->assign('lead', $lead);
        $this->assign('trends', $trends);
        $this->assign('trends2', $trends2);
        $this->assign('shfw', $shfw);
        $this->assign('theme', $theme);
        $this->assign('myfc', $myfc);
        $this->assign('yqlj', $yqlj);
        return $this->view->fetch();
    }
    //新闻公告详情页
    public function detail()
    {
        //接收id
        $id = input('id');
        if(empty($id)){
            return $this->fetch();
        }
        //导航条表查询
        $nav = NavModel::select();
        //轮播图表
        $banner = BannerModel::select();
        //查询新闻公告信息
        $data = NoticeModel::where('id','=',$id)->find();
        $this->assign('article',$data);
        $this->assign('nav', $nav);
        $this->assign('banner', $banner);
        return $this->fetch();
    }

}

